<template>
	<view class="page">
		<view class="flex0">
			<u-navbar :fixed='false' bgColor="transparent" @leftClick="navBack" title="学生心理健康服务平台">
				<view slot="center" class="navTitle">
					学生心理健康服务平台
				</view>
			</u-navbar>
		</view>

		<view class="flex1">
			<scroll-view scroll-y="true" class="scrollView pt30">
				<div class="banner pd30" v-if="banner&&banner.length>0">
					<div class="banIn">
						<swiper :circular="true" :indicator-dots="true" :autoplay="true" :interval="3000"
							:duration="1000" indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#ff6e1f">
							<swiper-item v-for="(item,index) in banner" :key="index">
								<image :src="item.picUrl" mode="aspectFill"></image>
							</swiper-item>
						</swiper>
					</div>
				</div>
				<view class="floor pd30" v-if="info.knowledge&&info.knowledge.length>0">
					<view class="floorTit">
						<view class="tit">
							<image src="@/static/images/title1.png" mode="heightFix"></image>
						</view>
						<navigator url="" open-type="navigate" class="more">
							<text>更多</text>
							<view class="ico">
								<image src="@/static/images/icon-more.png" mode="aspectFit"></image>
							</view>
						</navigator>
					</view>
					<view class="floorCon">
						<scroll-view scroll-x="true" class="xScroller">
							<view class="xScrollFlex">
								<navigator url="" open-type="navigate" class="knowledgeCard"
									v-for="(i,idx) in knowledge" :key="idx">
									<view class="bg">
										<image src="@/static/images/boxbg1.png" mode="aspectFit"></image>
									</view>
									<view class="ico">
										<image src="@/static/images/icon-quato.png" mode="aspectFit"></image>
									</view>
									<view class="txt">
										<view class="it">
											{{i.title}}
										</view>
										<view class="ip">
											{{i.introduction}}
										</view>
									</view>
								</navigator>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="floor pd30 white" v-if="info.story&&info.story.length>0">
					<view class="floorTit">
						<view class="tit">
							<image src="@/static/images/title2.png" mode="heightFix"></image>
						</view>
						<navigator url="" open-type="navigate" class="more">
							<text>更多</text>
							<view class="ico">
								<image src="@/static/images/icon-more.png" mode="aspectFit"></image>
							</view>
						</navigator>
					</view>
					<view class="floorCon">
						<scroll-view scroll-x="true" class="xScroller">
							<view class="xScrollFlex">
								<navigator url="" open-type="navigate" class="storyCard" v-for="(i,idx) in info.story" :key="idx">
									<view class="img">
										<image :src="i.image" mode="widthFix"></image>
									</view>
									<view class="txt">
										<view class="it">
											{{i.title}}
										</view>
									</view>
								</navigator>
							</view>
						</scroll-view>
					</view>
				</view>
				<view class="floor pd30" v-if="info.article&&info.article.length>0">
					<view class="floorTit">
						<view class="tit">
							<image src="@/static/images/title3.png" mode="heightFix"></image>
						</view>
						<navigator url="" open-type="navigate" class="more">
							<text>更多</text>
							<view class="ico">
								<image src="@/static/images/icon-more.png" mode="aspectFit"></image>
							</view>
						</navigator>
					</view>
					<view class="floorCon">
						<scroll-view scroll-x="true" class="xScroller">
							<view class="xScrollFlex">
								<navigator url="" open-type="navigate" class="normalCard" v-for="(i,idx) in info.article" :key="idx">
									<view class="img">
										<image :src="i.image" mode="widthFix"></image>
									</view>
									<view class="txt">
										<view class="it">
											{{i.title}}
										</view>
										<view class="date">
											{{i.date}}
										</view>
									</view>
								</navigator>
							</view>
						</scroll-view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="flex0">
			<TabBar :active="0" type="tourist"></TabBar>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				banner: [],
				knowledge:[],
				info: {}
			}
		},
		methods: {
			// 获取banner
			getBanner() {

				this.$api.adList({
					position: 1
				}, res => {
					if (res.code == 200) {
						this.banner = res.data.list;
						console.log(this.banner,123141)
					}
				})
			},
			getInfo() {
				
					this.$api.articleList({
							pageNo: 1,
							pageSize: 10,
							parentId:6
					}, res => {
						if (res.code == 200) {
							this.knowledge = res.data.list
						}
					})
				var that = this;
				var res = {
					banner: ['../../static/upload/banner.png', '../../static/upload/banner.png',
						'../../static/upload/banner.png'
					],
					pendingWork: {
						id: 101,
						title: '2024新生开学心理测评',
						endDate: '2024.12.21',
						total: 3,
						completed: 1
					},
					knowledge: [{
							id: 101,
							title: '如何守护孩子心理健康?',
							info: '家长需要知道这6方面'
						},
						{
							id: 101,
							title: '面对孩子拖延接纳是改变的开始',
							info: '建议采用小步走，微习惯'
						},
						{
							id: 101,
							title: '如何守护孩子心理健康?',
							info: '家长需要知道这6方面'
						},
						{
							id: 101,
							title: '面对孩子拖延接纳是改变的开始',
							info: '建议采用小步走，微习惯'
						},
						{
							id: 101,
							title: '如何守护孩子心理健康?',
							info: '家长需要知道这6方面'
						},
						{
							id: 101,
							title: '面对孩子拖延接纳是改变的开始',
							info: '建议采用小步走，微习惯'
						}
					],
					story: [{
							id: 101,
							title: '父亲节即至，听听CUMTers久藏的心里话',
							image: '../../static/upload/index11.jpg'
						},
						{
							id: 101,
							title: '青听青语|这个宿舍我是一点也待不下去了!',
							image: '../../static/upload/index12.jpg'
						},
						{
							id: 101,
							title: '父亲节即至，听听CUMTers久藏的心里话',
							image: '../../static/upload/index11.jpg'
						},
						{
							id: 101,
							title: '青听青语|这个宿舍我是一点也待不下去了!',
							image: '../../static/upload/index12.jpg'
						}
					],
					article: [{
							id: 101,
							title: '谨防“开学综合征”!家长应关注这些求助信号',
							image: '../../static/upload/index21.jpg',
							date: '2024.09.10'
						},
						{
							id: 101,
							title: '面对孩子拖延，接纳是改变的开始',
							image: '../../static/upload/index22.jpg',
							date: '2024.09.10'
						},
						{
							id: 101,
							title: '谨防“开学综合征”!家长应关注这些求助信号',
							image: '../../static/upload/index21.jpg',
							date: '2024.09.10'
						},
						{
							id: 101,
							title: '面对孩子拖延，接纳是改变的开始',
							image: '../../static/upload/index22.jpg',
							date: '2024.09.10'
						},
					]
				};
				that.info = res;
			}
		},
		mounted() {
			this.getBanner()
			this.getInfo();
		}
	}
</script>

<style lang="scss" scoped>
	.banner {
		margin-bottom: 10rpx;

		.banIn {
			padding-bottom: 46.38%;
			position: relative;

			swiper {
				width: 100%;
				height: 100%;
				border-radius: 30rpx;
				overflow: hidden;
				position: absolute;
				left: 0;
				top: 0;

				image {
					display: block;
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.normalCard {
		flex: 0 0 auto;
		position: relative;
		width: 320rpx;
		z-index: 5;
		margin-right: 25rpx;
		border: none !important;
		opacity: 1 !important;
		outline: none !important;
		background: #fff !important;
		border-radius: 20rpx;
		overflow: hidden;
		white-space: normal;
		display: flex;
		flex-direction: column;

		&:before,
		&:after {
			display: none;
		}

		&:last-child {
			margin-right: 0;
		}

		.img {
			flex: 0 0 auto;
			width: 100%;

			image {
				display: block;
				width: 100%;
				height: auto;
			}
		}

		.txt {
			padding: 25rpx;
			flex: 1 1 auto;
			box-sizing: border-box;
			width: 100%;
			display: flex;
			flex-direction: column;

			.it {
				margin-bottom: 30rpx;
				font-size: 28rpx;
				line-height: 40rpx;
				max-height: 120rpx;
				overflow: hidden;
				color: #7a6458;
				flex: 1 1 auto;
				width: 100%;
			}

			.date {
				width: 100%;
				font-size: 22rpx;
				color: #897f7a;
				flex: 0 0 auto;
			}
		}
	}

	.storyCard {
		flex: 0 0 auto;
		position: relative;
		width: 320rpx;
		z-index: 5;
		margin-right: 25rpx;
		border: none !important;
		opacity: 1 !important;
		outline: none !important;
		background: none !important;
		border-radius: 20rpx;
		overflow: hidden;
		white-space: normal;

		&:before,
		&:after {
			display: none;
		}

		&:last-child {
			margin-right: 0;
		}

		.img {
			image {
				display: block;
				width: 100%;
				height: auto;
			}
		}

		.txt {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			padding: 0 25rpx 30rpx;
			box-sizing: border-box;
			z-index: 10;

			.it {
				font-size: 32rpx;
				line-height: 40rpx;
				color: #fff;
				max-height: 160rpx;
				overflow: hidden;
			}
		}
	}

	.knowledgeCard {
		flex: 0 0 auto;
		position: relative;
		width: 320rpx;
		height: 330rpx;
		z-index: 5;
		margin-right: 25rpx;
		border: none !important;
		opacity: 1 !important;
		outline: none !important;
		background: none !important;

		&:before,
		&:after {
			display: none;
		}

		&:last-child {
			margin-right: 0;
		}

		.bg {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
			z-index: -1;

			image {
				display: block;
				width: 100%;
				height: 100%;
			}
		}

		.ico {
			position: absolute;
			right: 30rpx;
			top: 20rpx;

			image {
				display: block;
				width: 85rpx;
				height: 60rpx;
			}
		}

		.txt {
			position: absolute;
			top: 125rpx;
			left: 0;
			width: 100%;
			bottom: 0;
			z-index: 5;
			padding: 0 25rpx 30rpx;
			box-sizing: border-box;
			white-space: normal;

			.it {
				font-size: 32rpx;
				line-height: 40rpx;
				max-height: 80rpx;
				overflow: hidden;
				color: #7a6458;
				margin-bottom: 20rpx;
			}

			.ip {
				font-size: 20rpx;
				line-height: 36rpx;
				max-height: 72rpx;
				overflow: hidden;
				color: #897f7a;
			}
		}
	}
</style>